
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Class Room - a room in an adventure game.
 *
 * This class is part of the "World of Zuul" application. 
 * "World of Zuul" is a very simple, text based adventure game.  
 *
 * A "Room" represents one location in the scenery of the game.  It is 
 * connected to other rooms via exits.  The exits are labelled north, 
 * east, south, west.  For each direction, the room stores a reference
 * to the neighboring room, or null if there is no exit in that direction.
 * 
 * @author  Michael Kölling and David J. Barnes
 * @version 2016.02.29
 */
public class Room 
{
    private String description;
    private HashMap<String,Room> rooms = new HashMap<>();
    private Food food;
    private Pokemon p;
    private HashMap<String,Integer> pokeballs = new HashMap<>();
    List<Pokemon> list = new ArrayList<>();
    //public Room northExit;
    //public Room southExit;
    //public Room eastExit;
    //public Room westExit;

    /*
     * Create a room described "description". Initially, it has
     * no exits. "description" is something like "a kitchen" or
     * "an open court yard".
     * @param description The room's description.
     */
    public Room(String description) 
    {
        this.description = description;

    }


    public void setPokeballs(String s,Integer num){
        this.pokeballs.put(s,num);
    }

    public Integer getPokeballs(){
        return this.pokeballs.get("pokeball");
    }

    public boolean checkPokeball(){
        if (!this.pokeballs.isEmpty()) {
            System.out.println("你找到并获得了"+this.pokeballs.get("pokeball")+"个精灵球");
            return true;
        }
        return false;
    }


    public void setExit(String description ,Room room){
        this.rooms.put(description,room);
    }

    public void printExits(){
        System.out.println("出口：");
        for(String str : rooms.keySet()){
            System.out.print(str + " ");
        }
        System.out.println();
    }


    public void addPokemon(Pokemon pokemon){
//        if(name=="小火龙"){
//            this.p = new Xiaohuolong();
//        }else if(name=="杰尼龟"){
//            this.p = new jienigui();
//        }
        this.p=pokemon;
    }

    public void dropPokeballs(){
        pokeballs.remove("pokeball");
    }

    public String checkPokemon() {
        if (this.p!=null){
            if (this.p.isOnRoom())return "遇到了宝可梦："+this.p.toString();
        }
        return "";
//        String str = "";
//
//        if(!(list.isEmpty())){
//            for (int i = 0; i < list.size(); i++) {
//
//                Pokemon p = list.get(i);
//                str += p.toString();
//            }
//            return str;
//        }else return str;
    }

    public Pokemon getPokemon(){
        return this.p;
    }

    public Room goNext(String direction){
        return this.rooms.get(direction);
    }
    /**
     * @return The description of the room.
     */
    public void getDescription()
    {
        System.out.println(description);
        System.out.println(this.checkPokemon());
    }

}
